<%@ Language=VBScript%>
<% 
	Session("FormName")="F31"
%>
<!--#include file=..\checkSession.inc-->
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<!--#include file=..\jvgrid.inc-->
<!--#include file="..\pageSelected.inc"-->
<%		
	bChucvu=Request("TxtChucvu")
	bTochuc=Request("TxtTochuc")
	bTen=Request("TxtTen")	
	Set ClsFun =server.CreateObject("Vinalines.ClsFunction")
	bComm=Request("bComm")
	bMa=Request("bMa")
	Loaitim=request("Loaitim")
	bsearch=request("Txtten")
	if bComm="display" then
		sSQL="Select * from Diachiluutru where IDLuutru=" & cstr(bMa) 
		Set RecDisplay=server.CreateObject("ADODB.Recordset")
		RecDisplay.CursorType=3
		RecDisplay.CacheSize=5
		RecDisplay.Open sSQL,Conn
		if RecDisplay.RecordCount then
			bMa=trim(RecDisplay("IDLuutru"))
			bTen=trim(RecDisplay("Ten"))
			bChucvu=trim(RecDisplay("Diachi"))
			bTochuc=trim(RecDisplay("Nguoiphutrach"))
		end if
		RecDisplay.Close
		set RecDisplay=nothing
	end if	
	Dim bTempComm
	dim bMsg
	Dim Msg	
	
	If Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F31",2)="1" or Session("IsAdmin") then	
	Select Case bComm
		Case "add"
			bTen=Request("TxtTen")
			bChucvu=Request("TxtChucvu")
			bPhone=Request("TxtPhone")
			bTochuc=Request("TxtTochuc")
			bEmail=Request("TxtEmail")
			sSQL="Insert into Diachiluutru(ten,diachi,nguoiphutrach)values('"& ClsFun.ModiString(bTen) &"','"& ClsFun.ModiString(bChucvu) &"','"& ClsFun.ModiString(bTochuc) &"')"
			Conn.Execute sSQL	
		case "delete"							
			sSQL="Select VTDen.diachiluutru from VTDi,VTDen,VTNoibo where VTDi.diachiluutru="& bMa &" or VTDen.diachiluutru="& bMa &" or VTnoibo.diachiluutru="& bMa
			Set RecKT=server.CreateObject("ADODB.Recordset")
			RecKT.CursorType=3
			RecKT.CacheSize=5
			RecKT.Open sSQL,Conn
			if RecKT.RecordCount then
				bmsg="&#208;&#7883;a ch&#7881; l&#432;u tr&#7919; &#273;ang &#273;&#432;&#7907;c li&#234;n k&#7871;t kh&#244;ng th&#7875; xo&#225; &#273;&#432;&#7907;c"
			else
				sSQL="Delete from Diachiluutru Where IDLuutru Like "& cstr(bMa)
				Conn.Execute sSQL	
			end if
			RecKT.Close
			Set RecKT=nothing			
		case "edit"
			bTen=Request("TxtTen")
			bChucvu=Request("TxtChucvu")
			bTochuc=Request("TxtTochuc")
			sSQL="Update Diachiluutru set nguoiphutrach='"& ClsFun.ModiString(bTochuc) _
				&"',ten='"& ClsFun.ModiString(bTen) _
				&"',Diachi='"& ClsFun.ModiString(bChucvu) _
				&"' Where IDLuutru Like '" & ClsFun.ModiString(bMa) & "'"
			Conn.Execute sSQL
	End Select
	End if	
	Set Rec=server.CreateObject("ADODB.Recordset") 
	rec.CursorType = 3
	rec.CacheSize=5		
	select case bComm
		case "search"	
			ssql="Select * from Diachiluutru where Ten like '%"& ClsFun.ModiString(bsearch) & "%' order by IDLuutru"
		case else
			Loaitim=""
			bsearch=""
			'ssql="Select * from Diachiluutru order by IDLuutru"
			sSQL="SELECT Diachiluutru.*, Nhom.Tennhom, Canbo.Hovaten FROM Diachiluutru INNER JOIN"
            sSQL=sSQL+" Nhom ON Diachiluutru.Diachi = Nhom.Manhom INNER JOIN Canbo ON Diachiluutru.Nguoiphutrach =Canbo.Macanbo"
	end select
	Dim nRecCount	' Number of records found
	Dim nPageCount	' Number of pages of records we have
	Dim nPage	' Current page number
	nPage=CLng(request("Page"))	
	if nPage="" then nPage=1
	rec.Open ssql,Conn
	if  rec.EOF and rec.BOF then
		nPageCount=0
	end if	
%>
<!--#include file="..\jvfunction.inc"-->
<script language=VBScript runat=server>
	Function KTTen(bValue)
		KTTen=false
		ssql="Select * from Diachiluutru where Ten like '"& ClsFun.ModiString(bValue) &"'"
		Set RecTemp=server.CreateObject("ADODB.Recordset") 
		RecTemp.Open ssql,Application("StrConn")
		if (not rectemp.BOF) and (not RecTemp.EOF) then
			KTTen=True
		end if
		Set  RecTemp=nothing
	End function
Function Paging(ByVal intPage, ByVal intPageCount, ByVal intRecordCount)
	Dim strQueryString
	Dim strScript
	Dim intStart
	Dim intEnd
	Dim strRet
	Dim i

	If intPage > intPageCount Then
		intPage = intPageCount
	ElseIf intPage < 1 Then 
		intPage = 1
	End If
	
	If intRecordCount = 0 Then
		'strRet = "No Records Found"
	ElseIf intPageCount = 1 Then
		'strRet = "End Of Hits"
	Else
		For i = 1 To Request.QueryString.Count
			If LCase(Request.QueryString.Key(i)) <> "page" Then
				strQueryString = strQueryString & "&" 
				strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Key(i)) & "=" 
				strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Item(i))
			End If
		Next

		For i = 1 To Request.Form.Count
			If LCase(Request.Form.Key(i)) <> "page" Then
				strQueryString = strQueryString & "&" 
				strQueryString = strQueryString & Server.URLEncode(Request.Form.Key(i)) & "=" 
				strQueryString = strQueryString & Server.URLEncode(Request.Form.Item(i))
			End If
		Next

		If Len(strQueryString) <> 0 Then
			strQueryString = "?" & Mid(strQueryString, 2) & "&"
		Else
			strQueryString = "?"
		End If

		strScript = Request.ServerVariables("SCRIPT_NAME") & strQueryString
	
		If intPage <= 10 Then
			intStart = 1
		Else
			If (intPage Mod 10) = 0 Then
				intStart = intPage - 9
			Else
				intStart = intPage - (intPage Mod 10) + 1
			End If
		End If

		intEnd = intStart + 9
		If intEnd > intPageCount Then intEnd = intPageCount
	
		'strRet = "Page " & intPage & " of " & intPageCount & ": "
	
		If intPage > 10 Then 
			strRet = strRet & "<a href=""" & strScript
			strRet = strRet & "page=" & intPage - 10 
			strRet = strRet & """><IMG border=0 SRC=../images/prev.gif></a> "
		End If
	
		For i = intStart To intEnd
			If i = intPage Then
				strRet = strRet & "<b><font color=A90A08>" & i & "</font></b> "
			Else
				strRet = strRet & "<a href=""" & strScript
				strRet = strRet & "page=" & i 
				strRet = strRet & """>" & i & "</a>"
				If i <> intEnd Then strRet = strRet & " "
			End If
		Next
	
		If intPage <> intPageCount and intPageCount > 10 Then
			strRet = strRet & " <a href=""" & strScript
			strRet = strRet & "page=" & intPage + 10 
			strRet = strRet & """><IMG border=0 SRC=../images/next.gif></a> "
		End If
	End If
	
	Paging = strRet
End Function
</script>

<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function ChangePage(){
	strURL= nhom.page.value;
	window.nhom.target="right";
	window.nhom.action=strURL;
	window.nhom.submit();
}

function CmdAdd_onclick() {	
	nhom.TxtTen.value="";
	nhom.TxtChucvu.value="";
	nhom.TxtTochuc.value="";
	nhom.sua.value=2;
	cmdenable(false);	
	Unlockdata();
	nhom.TxtTen.focus();	
}
function KTnhap(){	
	if (nhom.TxtTen.value==""){
		alert("Bạn cần phải nhập nơi lưu trữ");
		nhom.TxtTen.focus();
		return false;
	}
	if (nhom.TxtChucvu.value==""){
		alert("Cho biết bộ phận quản lý");
		nhom.TxtChucvu.focus();
		return false;
	}
	if (nhom.TxtTochuc.value==""){
		alert("Cho biết người phụ trách");
		nhom.TxtTochuc.focus();
		return false;
	}
	return true;
}
function cmdenable(bvalue){
	if (bvalue){
		nhom.CmdAdd.disabled= false;
		nhom.CmdDelete.disabled= false;
		nhom.CmdEdit.disabled= false;
		nhom.CmdSearch.disabled=false;
		nhom.CmdCancel.disabled= true;
		nhom.CmdOK.disabled= true;	
	}
	else {
		nhom.CmdAdd.disabled= true;
		nhom.CmdDelete.disabled= true;
		nhom.CmdEdit.disabled= true;
		nhom.CmdSearch.disabled=true;
		nhom.CmdCancel.disabled= false;
		nhom.CmdOK.disabled= false;
	}	
}

function CmdCancel_onclick() {
	cmdenable(true);
	nhom.CmdDelete.disabled= true;
	nhom.CmdEdit.disabled= true;
	nhom.CmdSearch.disabled=true;
	Lockdata();
	nhom.TxtTochuc.value="";
	nhom.TxtChucvu.value="";
	nhom.TxtTen.value="";
}

function Lockdata(){
	nhom.TxtTochuc.disabled=true;
	nhom.TxtChucvu.disabled=true;
	nhom.TxtTen.disabled=true;
}
function Unlockdata(){
	nhom.TxtTochuc.disabled=false;
	nhom.TxtChucvu.disabled=false;
	nhom.TxtTen.disabled=false;
}
function CmdDelete_onclick() {
	if (nhom.TxtTen.value==""){
		alert("Bạn hãy chọn thông tin cần xoá");
		return ;
	}
	if(!confirm("Bạn có muốn xoá không ?")){
		return false;	
	}
	b="frmdiachiluutru.asp?bma="+"<%=bma%>"+"&bComm=delete";
	window.nhom.target="right";
	window.nhom.action=b;
	window.nhom.submit();
}
function CmdEdit_onclick() {
	if (trim(nhom.TxtTen.value)==""){
		alert("Bạn hãy chọn thông tin cần sửa");
		return ;
	}
	cmdenable(false);
	nhom.TxtTungay.disabled=true;
	nhom.TxtDenngay.disabled=true;
	Unlockdata();
	nhom.sua.value=1;
	nhom.TxtTen.focus();
}
function CmdOK_onclick() {
	if (KTnhap()){
		if(nhom.sua.value==1){		
			b="frmdiachiluutru.asp?bma="+"<%=bma%>"+"&bComm=edit";					
		}
		else{
			b="frmdiachiluutru.asp?bma="+"<%=bma%>"+"&bComm=add";					
		}
		window.nhom.target="right";
		window.nhom.action=b;
		window.nhom.submit();
	}
}
function CmdLoc_onclick() {
	Unlockdata();
	nhom.TxtTen.focus();
}
function CmdSearch_onclick() {
	if (!nhom.TxtTen.disabled){		
		alert("Chọn ngày cần xem");
		return false;
	}	
	if (trim(nhom.TxtTungay.value)!=""){
		if(!isDate(trim(nhom.TxtTungay.value))){
			alert("Ngày không hợp lệ");
			nhom.TxtTungay.focus();
			return false;
		}
	}
	if(trim(nhom.TxtDenngay.value)!=""){
		if(!isDate(trim(nhom.TxtDenngay.value))){
			alert("Ngày không hợp lệ");
			nhom.TxtTungay.focus();
			return false;
		}
	}
	blink="frmKetqua.asp?bMa=<%=bma%>";
	window.nhom.action=blink;
	window.nhom.target="new"
	window.nhom.submit();	
}
function TxtChucvu_onchange() {
	nhom.target="right";
	nhom.action="frmdiachiluutru.asp?bComm=change&bMa=<%=bMa%>"
	nhom.submit();
}
function window_onload() {
	<%if request("sua")=1 then%>
		<%if bComm<>"edit" and bComm<>"add" and bComm<>"delete"  then%>
		cmdenable(false);
		Unlockdata();
		nhom.sua.value=1;
		<%else%>
		cmdenable(true);
		nhom.TxtTochuc.value="";
		nhom.TxtChucvu.value="";
		nhom.TxtTen.value="";
		Lockdata();
		nhom.sua.value="";
		<%end if%>
	<%else%>
		<%if request("sua")=2 then%>
			<%if bComm<>"edit" and bComm<>"add" and bComm<>"delete" then%>
			cmdenable(false);
			Unlockdata();
			nhom.sua.value=2;
			<%else%>			
			cmdenable(true);
			nhom.TxtTochuc.value="";
			nhom.TxtChucvu.value="";
			nhom.TxtTen.value="";
			Lockdata();
			nhom.sua.value="";
			<%end if%>
		<%end if%>
	<%end if%>
	if (!window.nhom.CmdAdd.disabled){
		window.nhom.CmdAdd.focus();
	}
}

function TxtTungay_onkeyup(str){
var keycode
keycode=window.event.keyCode
if (isEdit(keycode,str)){
	nhom.TxtTungay.value=editdate(trim(str))
}
}

function TxtDenngay_onkeyup(str){
var keycode
keycode=window.event.keyCode
if (isEdit(keycode,str)){
	nhom.TxtDenngay.value=editdate(trim(str))
}
}
//-->
</script>
<LINK href="../styles/styles.css" type=text/css rel=STYLESHEET>
<body bgcolor=#F8F9D9 style="font-family:Times New Roman" topmargin=0 leftmargin=0 LANGUAGE=javascript onload="return window_onload()">
<%if bMsg<>"" then%>
	<p align=center><font face="Times New Roman" size=3 color=red><%=bMsg%></font></p>
<%end if%>
<form name="nhom" method="post">
	<input type=hidden name=sua>
	<input type="hidden" name="strURL" value="">
    <P ALIGN="CENTER"><FONT size=3 COLOR=black FACE="Times New Roman">
    <b>DANH MỤC ÐỊA CHỈ LƯU TRỮ</b></FONT>
<table border="0" cellpadding="0" cellspacing="0" style="font-family:arial;BORDER-BOTTOM-STYLE: none; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: solid;border-collapse:collapse; border-left-color:#C0C0C0; border-right-color:#C0C0C0; border-top-color:#C0C0C0; border-bottom-color:#C0C0C0" width="100%" bgcolor="#BDD5D0" bordercolor="#111111">
   <tr>
			<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F31",2)="1" or Session("IsAdmin") then%>
				<td width="20%"><Button name="CmdAdd" style="Font-family: Arial;width:100%" LANGUAGE=javascript onclick="return CmdAdd_onclick()" accesskey="T"><u>T</u>hêm</Button></td>
				<%if trim(bMa)="" then%>
					<td width="20%"><Button disabled name="CmdDelete" style="Font-family: Arial;width:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><u>X</u>óa</Button></td>
					<td width="20%"><Button disabled name="CmdEdit" style="Font-family: Arial;width:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><u>S</u>ửa</Button></td>
				<%else%>
					<td width="20%"><Button name="CmdDelete" style="Font-family: Arial;width:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><u>X</u>óa</Button></td>
					<td width="20%"><Button name="CmdEdit" style="Font-family: Arial;width:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><u>S</u>ửa</Button></td>
				<%end if%>
				<td width="20%"><Button name="CmdOK" disabled=true style="Font-family: Arial;width:100%" LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
				<td width="20%"><Button name="CmdCancel" disabled=true style="Font-family: Arial;width:100%" LANGUAGE=javascript onclick="return CmdCancel_onclick()" accesskey="B"><p><u>B</u>ỏ qua</p></Button></td>
			<%else%>		
				<td width="20%"><Button name="CmdAdd" disabled=true style="Font-family: Arial;width:100%" LANGUAGE=javascript onclick="return CmdAdd_onclick()" accesskey="T"><u>T</u>hêm</Button></td>
				<td width="20%"><Button name="CmdDelete" disabled=true style="Font-family: Arial;width:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><u>X</u>óa</Button></td>
				<td width="20%"><Button name="CmdEdit" disabled=true style="Font-family: Arial;width:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><u>S</u>ửa</Button></td>
				<td width="20%"><Button name="CmdOK" disabled=true style="Font-family: Arial;width:100%" LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
				<td width="20%"><Button name="CmdCancel" disabled=true style="Font-family: Arial; width:100%" LANGUAGE=javascript onclick="return CmdCancel_onclick()" accesskey="B"><p><u>B</u>ỏ qua</p></Button></td>
			<%end if%>
        </tr>
	</table>
	<!-- Form nhap lieu -->
	<table width="100%" border="0" cellspacing="0" style="Font-family:Times new roman;font-size:12pt;BORDER-BOTTOM-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: none;border-collapse:collapse; border-left-color:#C0C0C0; border-right-color:#C0C0C0; border-top-color:#C0C0C0; border-bottom-color:#C0C0C0" bgcolor="#BDD5D0"> 
	<% if bcomm="display" then %>			
		<tr>
			<td width="20%">Nơi lưu trữ</td>
			<td width="40%">
            <input disabled maxLength=50 name="TxtTen" VALUE="<%=bTen%>" style="Font-family: Arial;width:100%" size="20"></td>
			<td width="20%" align=center>Từ ngày</td>
			<td width="20%">
            <input maxLength=10 name="TxtTungay" style="Font-family: Arial;width:100%" tabindex="10" LANGUAGE=javascript onkeyup="return TxtTungay_onkeyup(this.value)" size="20"></td>
		</tr>
		<tr>
			<td width="20%">Bộ phận quản lý</td>
			<td width="40%">
			  <%
				sSQL="Select * from nhom order by Tennhom"
				Set RecNhom=server.CreateObject("ADODB.Recordset")
				Recnhom.CursorType=3
				RecNhom.CacheSize=5
				RecNhom.Open sSQL,Conn
			  %>
				<Select Name=TxtChucvu size=1 disabled style="font-family:Arial;width:100%" LANGUAGE=javascript onchange="return TxtChucvu_onchange()">
					<Option value=""></Option>
					<%
						Do While not RecNhom.EOF
					%>
						<%if bChucvu=RecNhom("Manhom") then%>
						<Option selected value="<%=RecNhom("Manhom")%>"><%=RecNhom("Tennhom")%></Option>
						<%else%>
						<Option value="<%=RecNhom("Manhom")%>"><%=RecNhom("Tennhom")%></Option>
						<%end if%>
					<%
							RecNhom.MoveNext
						Loop
					%>
			  </td>			  
			  <td width="20%" align=center>Ðến ngày</td>
			  <td width="20%">
              <input maxLength=10 name="TxtDenngay" style="Font-family: Arial;width:100%" tabindex="11" LANGUAGE=javascript onkeyup="return TxtDenngay_onkeyup(this.value)" size="20"></td>
		</tr>
		<tr>
			<td width="20%" nowrap>Người phụ trách</td>
			<td width="40%">
			  <%
				sSQL="SELECT distinct canbo.macanbo,hovaten FROM Canbo INNER JOIN Canbo_Nhom ON Canbo.Macanbo = Canbo_Nhom.Macanbo where canbo_nhom.Manhom like '"& bChucvu &"'"
				Set RecNhom=server.CreateObject("ADODB.Recordset")
				Recnhom.CursorType=3
				RecNhom.CacheSize=5
				RecNhom.Open sSQL,Conn
			  %>
				<Select Name=TxtTochuc disabled size=1 style="font-family:Arial;width:100%">
					<Option value=""></Option>
					<%
						Do While not RecNhom.EOF
					%>
						<%if bTochuc=RecNhom("Macanbo") then%>
						<Option selected value="<%=RecNhom("Macanbo")%>"><%=RecNhom("hovaten")%></Option>
						<%else%>
						<Option value="<%=RecNhom("Macanbo")%>"><%=RecNhom("hovaten")%></Option>
						<%end if%>
					<%
							RecNhom.MoveNext
						Loop
					%>
				</Select>
			  </td>
			  <td width="20%">
				<select name="LoaiVT"  size="1" style="font-family: Arial; height: 23; position: relative; width:100%" tabindex="12">
					<option value=1>Công văn đến</option>
				    <option value=2>Công văn đi</option>
					<option value=3>Văn bản nội bộ</option>
					<option value=4>Quyết định</option>
				</select>
			  </td>
			  <td width="20%"><input type="button" value="Xem" name="CmdSearch" tabindex="13" language="javascript" onclick="return CmdSearch_onclick()" style="Font-family: Arial; position: relative; width:100%; height:23"></td>
		</tr>
	<%else%>
	    <tr>
			  <td width="20%">Nơi lưu trữ</td>
			  <%if bComm<>"change" then%>
				  <td width="40%">
                  <input disabled maxLength=50 name="TxtTen" style="Font-family: Arial;width:100%" size="20"></td>
			  <%else%>
				  <td width="40%">
                  <input disabled maxLength=50 name="TxtTen" value="<%=bTen%>" style="Font-family: Arial;width:100%" size="20"></td>
			  <%end if%>
			  <td width="20%" align=center>Từ ngày</td>
			  <td width="20%">
              <input disabled maxLength=10 name="TxtTungay" style="Font-family: Arial;width:100%" LANGUAGE=javascript onkeyup="return TxtTungay_onkeyup(this.value)" size="20"></td>
		</tr>
		<tr>
			  <td width="20%">Bộ phận quản lý</td>
			  <td width="40%">
			  <%
				sSQL="Select * from nhom order by Tennhom"
				Set RecNhom=server.CreateObject("ADODB.Recordset")
				Recnhom.CursorType=3
				RecNhom.CacheSize=5
				RecNhom.Open sSQL,Conn
			  %>
				<Select Name=TxtChucvu size=1 disabled style="font-family:Arial;width:100%"   LANGUAGE=javascript onchange="return TxtChucvu_onchange()">
					<Option value=""></Option>
					<%
						Do While not RecNhom.EOF
					%>
						<%if bChucvu=RecNhom("Manhom") then%>
						<Option selected value="<%=RecNhom("Manhom")%>"><%=RecNhom("Tennhom")%></Option>
						<%else%>
						<Option value="<%=RecNhom("Manhom")%>"><%=RecNhom("Tennhom")%></Option>
						<%end if%>
					<%
							RecNhom.MoveNext
						Loop
					%>
			  </td>			  
			  <td width="20%" align=center>Ðến ngày</td>
			  <td width="20%">
              <input disabled maxLength=10 name="TxtDenngay" style="Font-family: Arial;width:100%" LANGUAGE=javascript onkeyup="return TxtDenngay_onkeyup(this.value)" size="20"></td>
		</tr>
		<tr>
			  <td width="20%" nowrap>Người phụ trách</td>
			  <td width="40%" >
			  <%
				sSQL="SELECT distinct canbo.macanbo,hovaten FROM Canbo INNER JOIN Canbo_Nhom ON Canbo.Macanbo = Canbo_Nhom.Macanbo where canbo_nhom.Manhom like '"& request("TxtChucvu") &"'"
				Set RecNhom=server.CreateObject("ADODB.Recordset")
				Recnhom.CursorType=3
				RecNhom.CacheSize=5
				RecNhom.Open sSQL,Conn
			  %>
				<Select Name=TxtTochuc disabled  size=1 style="font-family:Arial;width:100%">
					<%
						Do While not RecNhom.EOF
					%>
						<Option value="<%=RecNhom("Macanbo")%>"><%=RecNhom("hovaten")%></Option>
					<%
							RecNhom.MoveNext
						Loop
					%>
				</Select>
			  </td>
			  <td width="20%">
				<select name="LoaiVT" disabled  size="1" style="font-family: arial; height: 23; position: relative; width:100%" tabindex="12">
					<option value=1>Công văn đến</option>
  				     <option value=2>Công văn đi</option>
					<option value=3>Văn bản nội bộ</option>
					<option value=4>Quyết định</option>
				</select>
			</td>
			  <td width="20%"><input type="button" value="Xem" tabindex="13"  name="CmdSearch" disabled language="javascript" onclick="return CmdSearch_onclick()" style="Font-family: Arial; position: relative; width:100%; height:23"></td>
		</tr>
	<%end if%>
    </table>
<!--</form>	-->
<!-- Danh sach dia chi luu tru -->
<!--<form name="Table" method="post" >	-->
<table  border="0" width="100%" style="Font-family:Times new roman;font-size:12pt;Border-color:#C0C0C0;BORDER-BOTTOM-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid" topmargin="0">
  <tr>
    <TD WIDTH="100%" COLSPAN="2" BGCOLOR="#173584" ALIGN="CENTER"><FONT COLOR=WHITE FACE="Times New Roman" SIZE=2><B>DANH SÁCH ÐỊA CHỈ LƯU TRỮ</B></TD>
  </tr>  
  <tr bgcolor="#bdd5d0">
    <td width="50%" align="center"><b>Nơi lưu trữ</b></td>
    <td width="50%" align="center"><b>Bộ phận quản lý</b></td>
  </tr>
<%	
	If Not Rec.Eof Then
		nRecCount = Rec.RecordCount
		Rec.PageSize = 20
		nPageCount = Rec.PageCount
		If nPage < 1 then
			nPage = 1			
		End If
		if nPage > nPageCount Then
			nPage=nPageCount
		end if
		cnt=(pg-1)*pgsize + 1		    
		STT=1
		rec.AbsolutePage=nPage
		howmanyrecs=0
		do while not Rec.EOF and howmanyrecs<rec.PageSize
			if (cnt/2=int(cnt/2)) then
				color="#eeeecc"
			else
				color="#F8F9D9"
			end if
%>  
  <tr id=mnu_<%=STT%> style="BORDER-RIGHT: #e7e7e7 1px solid; BORDER-TOP: #e7e7e7 1px solid; BORDER-LEFT: #e7e7e7 1px solid; COLOR: #666666; BORDER-BOTTOM: #e7e7e7 1px solid; HEIGHT: 21px; BACKGROUND-COLOR: <%=color%>" onmouseover="javascript:MouseOverMenu('mnu_<%=STT%>')" onmouseout="javascript:MouseOutMenu('mnu_<%=STT%>','<%=color%>')">
    <td width="50%" height="1"><a style='color:blue;text-decoration: none' href='frmdiachiluutru.asp?page=<%=nPage%>&bComm=display&bma=<%=Rec("IdLuutru")%>'><%=Rec("Ten")%></a></td>
    <td width="50%" height="1"><a style='color:blue;text-decoration: none' href='frmdiachiluutru.asp?page=<%=nPage%>&bComm=display&bma=<%=Rec("IdLuutru")%>'><%=Rec("tennhom")%></a></td>
  </tr>
<%			STT=STT+1
			Rec.MoveNext
			cnt=cnt+1
			howmanyrecs=howmanyrecs+1
		loop
	end if
	rec.Close
	set rec=nothing
	
%>  
</table>
<!--
</form>
  <%
response.write "<Table width='100%'>"
response.write "<TR>"
response.write "<TD width='15%' valign=top>"
response.write "<p align=left>Trang:  " & cstr(nPage) & "/" & cstr(nPageCount)
response.write "</TD>"
response.write "<TD>"

Response.Write "<font face=Time New Roman>" 
response.write "<p align=center>"
for counter=1 to nPageCount
	if bComm<>"search"  then
		txt="&nbsp;<a href='frmdiachiluutru.asp?bsearch="& bsearch &"&Loaitim="& loaitim &"&page="+ cstr(counter)+ "&bComm='>" & counter & "</a>&nbsp;"
	else
		txt="&nbsp;<a href='frmdiachiluutru.asp?bsearch="& bsearch &"&Loaitim="& loaitim &"&page="+ cstr(counter)+ "&bComm=search'>" & counter & "</a>&nbsp;"
	end if
	response.write(txt)
	if (counter mod 20)=0 then
		response.write "<br>"
	end if

next
Response.Write "</font>" 
response.write "</TD>"
response.write "</TR>"
response.write "</Table>" 
%>
</body>
</html>
-->
 <!-- Phan trang -->
<br>
<table width="98%" cellspacing=0 cellpadding=0>
<tr>
<% if nPage > 0  and nPageCount >0 then %>  
	<td width="20%"><b>Trang&nbsp; <%=nPage%>/<%=nPageCount%></b></td>
<!-- 	<td width= "80%" align="right">
	<% if nPageCount > 1 then %>    
		Chuyển nhanh tới trang:&nbsp;
		<select name="page" style="width:45;height:23;font-size:8pt" size=1 onchange="javaScript:ChangePage()">
			<% for i = 1 to nPageCount%>	
				<% if bComm<>"search"  then
					strURL="frmdiachiluutru.asp?bsearch="& bsearch &"&Loaitim="& loaitim &"&page="+ cstr(i)+ "&bComm="
				else
					strURL="frmdiachiluutru.asp?bsearch="& bsearch &"&Loaitim="& loaitim &"&page="+ cstr(i)+ "&bComm=search"
				end if %>
				<option value="<%=strURL%>" <%=chkSelected(i, nPage)%>><%=i%></option>
			<% next %>    
		</select>
		</td>                                  
	<% end if %>              -->
<% 'else %>
<% end if %>
<td width= "80%" align="center"><%=Paging(nPage, nPageCount, nRecCount)%></td>
</tr>
</table>
</body>
</form>
</html>
<%
	Conn.Close
	Set Conn=nothing
	set ClsFun=nothing
%>